<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
	
<head>
	<title>安装 与 介绍 — Vue.js</title>
	<meta charset="utf-8">
	<meta name="description" content="Vue.js - The Progressive JavaScript Framework">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

	<script src="/js/jquery-3.1.0.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="/js/prettify.js"></script>
	<script type="text/javascript" src="/js/content.js"></script>
	<link rel="stylesheet" href="/css/prettify.css">
	<link rel="icon" href="/images/logo.png" type="image/png">


	<link rel="stylesheet" type="text/css" href="/css/vuex.css"/>
	<script type="text/javascript" src="/js/vue.js"></script>



	<!-- main page styles -->
	<link rel="stylesheet" href="/css/page.css">
<style type="text/css">
	.content .linenums>ol {
		margin: 0;
		padding-left:35px;
	}
	.hljs-comment,.hljs-quote{color:#8e908c}
	.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#c82829}
	.hljs-built_in,.hljs-builtin-name,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5871f}
	.hljs-attribute{color:#eab700}
	.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#718c00}
	.hljs-section,.hljs-title{color:#4271ae}
	.hljs-keyword,.hljs-selector-tag{color:#8959a8}
	.hljs{display:block;overflow-x:auto;background:#fff;color:#4d4d4c;padding:.5em}
	.hljs-emphasis{font-style:italic}
	.hljs-strong{font-weight:700}
</style>
</head>

<body class="docs">


<div id="header">
	<a id="logo" href="https://cn.vuejs.org/">
		<img src="/images/logo.png">
		<span>Vuecli</span>
	</a>
</div>


<div id="main" class="fix-sidebar">
	<div class="sidebar">
		<div class="sidebar-inner">
			<div class="list">
			<ul class="menu-root">
	<li>
		<h3>知识点</h3>
	</li>
	<li id="stylus" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/stylus" class="sidebar-link">stylus</a>
		<ul class="menu-sub">
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/stylus#变量">变量</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/stylus#@import引入">@import引入</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/stylus#特殊用法">特殊用法</a>
			</li>
		</ul>
	</li>

	<li id="transfer" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/transfer" class="sidebar-link">框架数据传递 全局函数</a>
		<ul class="menu-sub">
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/transfer#func">第三方全局函数</a>
			</li>
		</ul>
	</li>

	<li id="axios" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/axios" class="sidebar-link">axios</a>
		<ul class="menu-sub">
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#Features">Features</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#浏览器支持">浏览器支持</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#安装">安装</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#Example">Example</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#API">axios API</a>
			</li>
			<ul>
				<li>
					<a class="section-link" data-scroll="" href="/Vuecli/axios#请求方法的别名">请求方法的别名</a>
				</li>
				<li>
					<a class="section-link" data-scroll="" href="/Vuecli/axios#并发">并发</a>
				</li>
				<li>
					<a class="section-link" data-scroll="" href="/Vuecli/axios#创建实例">创建实例</a>
				</li>
				<li>
					<a class="section-link" data-scroll="" href="/Vuecli/axios#实例方法">实例方法</a>
				</li>
			</ul>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#请求配置">请求配置</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#响应结构">响应结构</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#defaults">配置的默认值/defaults</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#拦截器">拦截器</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#错误处理">错误处理</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#取消">取消</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/axios#Semver">Semver</a>
			</li>
		</ul>
	</li>
	
	
	<li>
		<h3>框架布局</h3>
	</li>
	<li id="mulujiegou" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/mulujiegou" class="sidebar-link">目录结构</a>
		<ul class="menu-sub">
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#路径配置import">路径配置import</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#总体框架">总体框架</a>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#文件结构细分">文件结构细分</a>
				<ul>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#build">build - [webpack配置]</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#config">config - [vue项目配置]</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#node_modules">node_modules - [依赖包]</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/mulujiegou#router">router - [路由配置]</a>
					</li>
				</ul>
			</li>
		</ul>
	</li>


	<li id="huanjingpeizhi" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/huanjingpeizhi" class="sidebar-link">基于webpack 环境配置</a>
		<ul class="menu-sub">
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#运行服务器">运行服务器</a>
				<ul>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#运行服务器0">运行服务器 cmd</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#cmd其他操作命令">cmd其他操作命令</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#代码初始化">代码初始化</a>
				<ul>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#viewport">viewport index.html</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#resetcss">reset.css 样式初始化</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#stylus_install">安装 stylus</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#fastclick">fastclick.js 解决点击延时</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#bordercss">border.css 1像素边框</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#iconfont">iconfont</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#安装">安装</a>
				<ul>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#node">安装node.js LTS版本 cmd</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#vuecli">安装vue-cil 全局安装一次 cmd</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#webpack">创建 webpack模板的项目 cmd</a>
					</li>
					<li>
						<a class="section-link" data-scroll="" href="/Vuecli/huanjingpeizhi#cnpm">使用cnmp</a>
					</li>
				</ul>
			</li>
		</ul>
	</li>
	


	<li>
		<h3>Vue Router</h3>
	</li>
	<li id="vrouter-van" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vrouter-van" class="sidebar-link">van: 基于vue-cil的使用</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vrouter-van#indexjs" data-scroll="" class="section-link">@/router/index.js</a></li>
		</ul>
	</li>
	<li id="vrouter-start" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vrouter-start" class="sidebar-link">安装 与 介绍</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vrouter-start#installation" data-scroll="" class="section-link">安装</a></li>
			<li><a href="/Vuecli/vrouter-start#introduce" data-scroll="" class="section-link">介绍</a></li>
		</ul>
	</li>
	<li id="vrouter-basic" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vrouter-basic" class="sidebar-link">基础</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vrouter-basic#start" class="section-link">起步</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#start-html" class="section-link">HTML</a></li>
				<li><a href="/Vuecli/vrouter-basic#start-javascript" class="section-link">JavaScript</a></li>
			</ul>

			<li><a href="/Vuecli/vrouter-basic#dynamic_matching" class="section-link">动态路由匹配</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#dynamic_matching-响应路由参数的变化" class="section-link">响应路由参数的变化</a></li>
				<li><a href="/Vuecli/vrouter-basic#dynamic_matching-高级匹配模式" class="section-link">高级匹配模式</a></li>
				<li><a href="/Vuecli/vrouter-basic#dynamic_matching-匹配优先级" class="section-link">匹配优先级</a></li>
			</ul>

			<li><a href="/Vuecli/vrouter-basic#nested-routes" class="section-link">嵌套路由</a></li>
			
			<li><a href="/Vuecli/vrouter-basic#navigation" class="section-link">编程式的导航</a></li>
			
			<li><a href="/Vuecli/vrouter-basic#named-routes" class="section-link">命名路由</a></li>
			
			<li><a href="/Vuecli/vrouter-basic#named_views" class="section-link">命名视图</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#named_views-嵌套命名视图" class="section-link">嵌套命名视图</a></li>
			</ul>

			<li><a href="/Vuecli/vrouter-basic#redirect_and_alias" class="section-link">重定向和别名</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#redirect_and_alias-重定向" class="section-link">重定向</a></li>
				<li><a href="/Vuecli/vrouter-basic#redirect_and_alias-别名" class="section-link">别名</a></li>
			</ul>

			<li><a href="/Vuecli/vrouter-basic#passing_props" class="section-link">路由组件传参</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#passing_props-布尔模式" class="section-link">布尔模式</a></li>
				<li><a href="/Vuecli/vrouter-basic#passing_props-对象模式" class="section-link">对象模式</a></li>
				<li><a href="/Vuecli/vrouter-basic#passing_props-函数模式" class="section-link">函数模式</a></li>
			</ul>

			<li><a href="/Vuecli/vrouter-basic#history_mode" class="section-link">HTML5 History 模式</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-basic#history_mode-后端配置例子" class="section-link">后端配置例子</a></li>
				<li><a href="/Vuecli/vrouter-basic#history_mode-警告" class="section-link">警告</a></li>
			</ul>
		</ul>
	</li>
	<li id="vrouter-advanced" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vrouter-advanced" class="sidebar-link">进阶</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vrouter-advanced#navigation_guards" class="section-link">导航守卫</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-全局守卫" class="section-link">全局守卫</a></li>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-全局解析守卫" class="section-link">全局解析守卫</a></li>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-全局后置钩子" class="section-link">全局后置钩子</a></li>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-路由独享的守卫" class="section-link">路由独享的守卫</a></li>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-组件内的守卫" class="section-link">组件内的守卫</a></li>
				<li><a href="/Vuecli/vrouter-advanced#navigation_guards-完整的导航解析流程" class="section-link">完整的导航解析流程</a></li>
			</ul>
		
			<li><a href="/Vuecli/vrouter-advanced#meta" class="section-link">路由元信息</a></li>
		
			<li><a href="/Vuecli/vrouter-advanced#transitions" class="section-link">过渡动效</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-advanced#transitions-单个路由的过渡" class="section-link">单个路由的过渡</a></li>
				<li><a href="/Vuecli/vrouter-advanced#transitions-基于路由的动态过渡" class="section-link">基于路由的动态过渡</a></li>
			</ul>
		
			<li><a href="/Vuecli/vrouter-advanced#data_fetching" class="section-link">数据获取</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-advanced#data_fetching-导航完成后获取数据" class="section-link">导航完成后获取数据</a></li>
				<li><a href="/Vuecli/vrouter-advanced#data_fetching-在导航完成前获取数据" class="section-link">在导航完成前获取数据</a></li>
			</ul>
		
			<li><a href="/Vuecli/vrouter-advanced#scroll_behavior" class="section-link">滚动行为</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-advanced#scroll_behavior-异步滚动" class="section-link">异步滚动</a></li>
			</ul>
		
			<li><a href="/Vuecli/vrouter-advanced#lazy_loading" class="section-link">路由懒加载</a></li>
			<ul>
				<li><a href="/Vuecli/vrouter-advanced#lazy_loading-把组件按组分块" class="section-link">把组件按组分块</a></li>
			</ul>
		</ul>
	</li>


	<li>
		<h3>Vuex</h3>
	</li>
	<li id="vuex-start" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuex-start" class="sidebar-link">安装 与 介绍</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuex-start#installation" data-scroll="" class="section-link">安装</a></li>
			<li><a href="/Vuecli/vuex-start#introduce" data-scroll="" class="section-link">Vuex 是什么？</a></li>
			<li><a href="/Vuecli/vuex-start#vrouter-basic0" data-scroll="" class="section-link">开始</a></li>
		</ul>
	</li>
	<li id="vuex-guide" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuex-guide" class="sidebar-link">核心概念</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuex-guide#state" data-scroll="" class="section-link">State</a></li>
			<li><a href="/Vuecli/vuex-guide#getters" data-scroll="" class="section-link">Getter</a></li>
			<li><a href="/Vuecli/vuex-guide#mutations" data-scroll="" class="section-link">Mutation</a></li>
			<li><a href="/Vuecli/vuex-guide#actions" data-scroll="" class="section-link">Action</a></li>
			<li><a href="/Vuecli/vuex-guide#modules" data-scroll="" class="section-link">Module</a></li>
		</ul>
	</li>
	<li id="vuex-important" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuex-important" class="sidebar-link">重点知识</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuex-important#structure" data-scroll="" class="section-link">项目结构</a></li>
			<li><a href="/Vuecli/vuex-important#plugins" data-scroll="" class="section-link">插件</a></li>
			<li><a href="/Vuecli/vuex-important#strict" data-scroll="" class="section-link">严格模式</a></li>
			<li><a href="/Vuecli/vuex-important#forms" data-scroll="" class="section-link">表单处理</a></li>
			<li><a href="/Vuecli/vuex-important#testing" data-scroll="" class="section-link">测试</a></li>
			<li><a href="/Vuecli/vuex-important#hot-reload" data-scroll="" class="section-link">热重载</a></li>
		</ul>
	</li>


	<li>
		<h3>Vue-CLI</h3>
	</li>
	<li id="vuecli-start" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuecli-start" class="sidebar-link">安装 与 介绍</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuecli-start#introduce" data-scroll="" class="section-link">介绍</a></li>
			<li><a href="/Vuecli/vuecli-start#installation" data-scroll="" class="section-link">安装</a></li>
		</ul>
	</li>
	<li id="vuecli-basic" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuecli-basic" class="sidebar-link">基础</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuecli-basic#prototyping" data-scroll="" class="section-link">快速原型开发</a></li>
			<li><a href="/Vuecli/vuecli-basic#creating-a-project" data-scroll="" class="section-link">创建一个项目</a></li>
			<li><a href="/Vuecli/vuecli-basic#plugins-and-presets" data-scroll="" class="section-link">插件和 Preset</a></li>
			<li><a href="/Vuecli/vuecli-basic#cli-service" data-scroll="" class="section-link">CLI 服务</a></li>
		</ul>
	</li>
	<li id="vuecli-develop" class="sidebar-menu">
		<i class="">＋</i>
		<a href="/Vuecli/vuecli-develop" class="sidebar-link">开发</a>
		<ul class="menu-sub">
			<li><a href="/Vuecli/vuecli-develop#browser-compatibility" data-scroll="" class="section-link">浏览器兼容性</a></li>
			<li><a href="/Vuecli/vuecli-develop#html-and-static-assets" data-scroll="" class="section-link">HTML 和静态资源</a></li>
			<li><a href="/Vuecli/vuecli-develop#css" data-scroll="" class="section-link">CSS 相关</a></li>
			<li><a href="/Vuecli/vuecli-develop#webpack" data-scroll="" class="section-link">webpack 相关</a></li>
			<li><a href="/Vuecli/vuecli-develop#mode-and-env" data-scroll="" class="section-link">环境变量和模式</a></li>
			<li><a href="/Vuecli/vuecli-develop#build-targets" data-scroll="" class="section-link">构建目标</a></li>
			<li><a href="/Vuecli/vuecli-develop#deployment" data-scroll="" class="section-link">部署</a></li>
		</ul>
	</li>
	
</ul>

			</div>
		</div>
	</div>

	
<div class="content guide with-sidebar components-guide">
<h1>安装 与 介绍</h1>	

<h2 id="installation">
	<a href="#installation" class="headerlink" title="installation" data-scroll="">安装</a>
</h2>	
<h3 id="直接下载-cdn"><a href="#直接下载-cdn" aria-hidden="true" class="header-anchor">#</a> 直接下载 / CDN</h3>
<p><a href="https://unpkg.com/vue-router/dist/vue-router.js" target="_blank" rel="noopener noreferrer">https://unpkg.com/vue-router/dist/vue-router.js<svg
		 xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"
		 class="icon outbound">
			<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path>
			<polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon>
		</svg></a></p>
<p><a href="https://unpkg.com" target="_blank" rel="noopener noreferrer">Unpkg.com<svg xmlns="http://www.w3.org/2000/svg"
		 aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound">
			<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path>
			<polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon>
		</svg></a> 提供了基于 NPM 的 CDN 链接。上面的链接会一直指向在 NPM 发布的最新版本。你也可以像 <code>https://unpkg.com/vue-router@2.0.0/dist/vue-router.js</code>
	这样指定 版本号 或者 Tag。
</p>
<p>在 Vue 后面加载 <code>vue-router</code>，它会自动安装的：</p>
<div class="language-html extra-class">
	<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>/path/to/vue.js<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>/path/to/vue-router.js<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre>
</div>
<h3 id="npm"><a href="#npm" aria-hidden="true" class="header-anchor">#</a> NPM</h3>
<div class="language-bash extra-class">
	<pre class="language-bash"><code><span class="token function">npm</span> <span class="token function">install</span> vue-router
</code></pre>
</div>
<p>如果在一个模块化工程中使用它，必须要通过 <code>Vue.use()</code> 明确地安装路由功能：</p>
<div class="language-js extra-class">
	<pre class="language-js"><code><span class="token keyword">import</span> Vue <span class="token keyword">from</span> <span class="token string">'vue'</span>
<span class="token keyword">import</span> VueRouter <span class="token keyword">from</span> <span class="token string">'vue-router'</span>

Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>VueRouter<span class="token punctuation">)</span>
</code></pre>
</div>
<p>如果使用全局的 script 标签，则无须如此 (手动安装)。</p>
<h3 id="构建开发版"><a href="#构建开发版" aria-hidden="true" class="header-anchor">#</a> 构建开发版</h3>
<p>如果你想使用最新的开发版，就得从 GitHub 上直接 clone，然后自己 build 一个 <code>vue-router</code>。</p>
<div class="language-bash extra-class">
	<pre class="language-bash"><code><span class="token function">git</span> clone https://github.com/vuejs/vue-router.git node_modules/vue-router
<span class="token function">cd</span> node_modules/vue-router
<span class="token function">npm</span> <span class="token function">install</span>
<span class="token function">npm</span> run build
</code></pre>
</div>


<br><br>


<h2 id="introduce">
	<a href="#introduce" class="headerlink" title="introduce" data-scroll="">介绍</a>
</h2>	
<p class="bit-sponsor"><a href="https://www.bitsrc.io/?utm_source=vue&amp;utm_medium=vue&amp;utm_campaign=vue&amp;utm_term=vue&amp;utm_content=vue"
	 target="_blank"><span>This project is sponsored by</span> <img alt="bit" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/bit-wide.png"></a></p>
<div class="tip custom-block">
	<p class="custom-block-title">版本说明</p>
	<p>对于 TypeScript 用户来说，<code>vue-router@3.0+</code> 依赖 <code>vue@2.5+</code>，反之亦然。</p>
</div>
<p>Vue Router 是 <a href="http://cn.vuejs.org" target="_blank" rel="noopener noreferrer">Vue.js<svg xmlns="http://www.w3.org/2000/svg"
		 aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound">
			<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path>
			<polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon>
		</svg></a> 官方的路由管理器。它和 Vue.js 的核心深度集成，让构建单页面应用变得易如反掌。包含的功能有：</p>
<ul>
	<li>嵌套的路由/视图表</li>
	<li>模块化的、基于组件的路由配置</li>
	<li>路由参数、查询、通配符</li>
	<li>基于 Vue.js 过渡系统的视图过渡效果</li>
	<li>细粒度的导航控制</li>
	<li>带有自动激活的 CSS class 的链接</li>
	<li>HTML5 历史模式或 hash 模式，在 IE9 中自动降级</li>
	<li>自定义的滚动条行为</li>
</ul>
<p>现在开始<a href="/zh/guide/" class="">起步</a>或尝试一下我们的<a href="https://github.com/vuejs/vue-router/tree/dev/examples"
	 target="_blank" rel="noopener noreferrer">示例<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px"
		 viewBox="0 0 100 100" width="15" height="15" class="icon outbound">
			<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path>
			<polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon>
		</svg></a>吧 (查看仓库的 <a href="https://github.com/vuejs/vue-router/" target="_blank" rel="noopener noreferrer"><code>README.md</code><svg
		 xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"
		 class="icon outbound">
			<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path>
			<polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon>
		</svg></a> 来运行它们)。</p>



<br><br>


	
</div>
		<!-- important -->

<!-- var end -->
</div>	<!-- #main -->

<script>
	
var thisAction = '<?php echo ($thisAction); ?>';

if (thisAction == 'all') {
	// sidebar全部显示
	var $link = $('.content .headerlink');
	var $slink = $('.section-link');
	
}else {
	// 仅展开 当前actionName
	$('.menu-sub').hide();
	$('#'+thisAction+'>a').addClass('current'); 
	$('#'+thisAction+'>i').addClass('sidebar-tap').html('－');
	$('#'+thisAction+' .menu-sub').show();


	$('.sidebar-menu>i').click(function(){
		if($(this).hasClass('sidebar-tap')) {
			$(this).html('＋').toggleClass('sidebar-tap');
			$(this).siblings('.menu-sub').hide();
		}else {
			$('.sidebar-menu>i').html('＋').removeClass('sidebar-tap');
			$('.sidebar-menu .menu-sub').hide();

			$(this).html('－').toggleClass('sidebar-tap');
			$(this).siblings('.menu-sub').show();
		}
	});


	let href = window.location.href;
	let start = href.indexOf('#');
	let href2 = '';
	if(start > 0) {
		href2 = href.slice(start+1);
		$('#'+thisAction+' .section-link[href="#'+href2+'"]').addClass('active');
	}else {
		$('#'+thisAction+' .menu-sub .section-link:first').addClass('active');
	}
 
	var $link = $('.content .headerlink');
	var $slink = $('#'+thisAction+' .menu-sub .section-link');
	
	$('#'+thisAction+' .section-link').click(function(){
		$slink.removeClass('active');
		$(this).addClass('active');
	});
}



// 页面滚动 .sidebar提示 start
let scrollArr = [];
$.each( $link, function() {
	let offset = $(this).offset();
	let thisId = $(this).attr('id');
	scrollArr.push(offset.top);
});


$(window).on('scroll', function(){
	let scrollTop = $(document).scrollTop();
	let nap = 110;
	let slength = scrollArr.length;
	let i=0;
	if(scrollTop < (scrollArr[0]-nap) ) {
	}else if(scrollTop >= scrollArr[slength-1]-nap) {
		i = slength-1;
	}else {
		for(i=0; i<scrollArr.length; i++) {
			if(scrollTop>=scrollArr[i]-nap && scrollTop<scrollArr[i+1]-nap) {
				break;
			}
		}
	}

	if($slink.eq(i).length > 0){
		$slink.removeClass('active');
		$slink.eq(i).addClass('active');
	}
});


</script>

    
  </body>
</html>